



//
//  NRenzhengAndCuibaoVC.m
//  nncloud
//
//  Created by macfai on 2018/11/29.
//  Copyright © 2018 macfai. All rights reserved.
//

#import "NRenzhengAndCuibaoVC.h"
#import "NQiyebanshiCell.h"
#import "NMsgModel.h"

@interface NRenzhengAndCuibaoVC ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong)UITableView *tableView;

@property (nonatomic,strong)NSMutableArray *dataArray;

@property (nonatomic,strong)NSArray *titles;


@end

@implementation NRenzhengAndCuibaoVC

#define cellIdentifier @"qiye"
#define SectionHeaderHeight 15.f

-(UITableView *)tableView{
    
    if (!_tableView) {
        WeakStament(ws);
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0 , 0, ScreenWidth , ScreenHeight - 64) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.rowHeight = 85.0f;
        //        _tableView.separatorColor = [UIColor clearColor];
        _tableView.backgroundColor = kBackgroundColor;
        [_tableView registerNib:[UINib nibWithNibName:@"NQiyebanshiCell" bundle:nil] forCellReuseIdentifier:cellIdentifier];
        
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.tableFooterView = [UIView new];
        
    }
    return _tableView;
}
- (void)viewDidLoad {
    
    [super viewDidLoad];
    self.view.backgroundColor = kWhiteColor;
    self.dataArray = [NSMutableArray array];
    //催报通知认证通知
    if (_atitle) {
         [self.navigationItem setItemWithTitle:_atitle textColor:kNavigationTitleColor fontSize:18 itemType:center];
    }
    
    self.titles = @[@"工业填报，财务填报及其他东西",@"工业填报，财务填报及其他东西",@"工业填报，财务填报及其他东西",@"工业填报，财务填报及其他东西",];
    
    [self.view addSubview:self.tableView];
  
    [self loadData];
//    self.unitArray = [NSMutableArray array];
    // Do any additional setup after loading the view.
}

///字典 冒号  自贸   对象  等号   对等
- (void)loadData{
    //如果不传用户ID则messageType
    if (!self.msgType) {
        return;
    }
    NSDictionary *dic = @{@"messageUserId":[NUserModel shareInstance].userInfoId?:@"",@"messageType":self.msgType,@"size":@(10),@"curPage":@(1)};
    [[NNRCNetRequest manager]getWithUrl:kMsgNotiListUrl params:dic success:^(id result) {
        YYLog(@"%@",result);
        WeakStament(ws);
        if ([[result objectForKey:@"code"] integerValue] == 0) {
            NSArray *arr = result[@"page"][@"records"];
            YYLog(@"%@",arr);
            if (arr.count>0) {
                for (NSDictionary *dict in arr) {
                    NMsgModel *model = [NMsgModel mj_objectWithKeyValues:dict];
                    [ws.dataArray addObject:model];
                }
                [ws.tableView reloadData];
            }else{
                ///返回数组中没有数据
//                [AFToast showText:result[@"msg"]];
                [AFToast showText:@"数据返回为空"];
            }
            
        }else{
            [AFToast showText:result[@"msg"]];
        }
    } failure:^(id failure) {
        
    }];
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
//    return self.titles.count;

    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NQiyebanshiCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];
    NMsgModel *model = self.dataArray[indexPath.row];
    cell.nameLabel.text = model.messageContent;
    cell.img.image = WDImgName(_atitle);
    return cell;
}


#pragma mark - section head
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return SectionHeaderHeight;//如果设置section的header高度，不设置footer高度，footer默认等于header高度
}



- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, ScreenWidth, SectionHeaderHeight)];
    view.backgroundColor = kBackgroundColor;
    return view;
}

#pragma mark - section foot
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section{
    return nil;
}



///安卓iOS返回的对象的数据格式
/*
 {
 msg = "success",
 page =     {
 records =     (
 {
 messageId = 144,
 messageReadFlag = "0",
 messageUserId = 5,
 messageCreateTime = 1543914721000,
 messageQuestionId = 2,
 messageContent = "【财务填报】财务填报002",
 messageType = "2",
 },
 {
 messageId = 147,
 messageReadFlag = "0",
 messageUserId = 5,
 messageCreateTime = 1543914721000,
 messageQuestionId = 2,
 messageContent = "【工业填报】工业填报001",
 messageType = "2",
 },
 {
 messageId = 145,
 messageReadFlag = "0",
 messageUserId = 5,
 messageCreateTime = 1543914721000,
 messageQuestionId = 2,
 messageContent = "【财务填报】财务填报002",
 messageType = "2",
 },
 {
 messageId = 143,
 messageReadFlag = "0",
 messageUserId = 5,
 messageCreateTime = 1543914721000,
 messageQuestionId = 2,
 messageContent = "【财务填报】财务填报002",
 messageType = "2",
 },
 {
 messageId = 146,
 messageReadFlag = "0",
 messageUserId = 5,
 messageCreateTime = 1543914721000,
 messageQuestionId = 2,
 messageContent = "【财务填报】财务填报002",
 messageType = "2",
 },
 {
 messageId = 142,
 messageReadFlag = "0",
 messageUserId = 5,
 messageCreateTime = 1543914721000,
 messageQuestionId = 2,
 messageContent = "【财务填报】财务填报002",
 messageType = "2",
 },
 {
 messageId = 141,
 messageReadFlag = "0",
 messageUserId = 5,
 messageCreateTime = 1543914721000,
 messageQuestionId = 2,
 messageContent = "【财务填报】财务填报002",
 messageType = "2",
 },
 {
 messageId = 140,
 messageReadFlag = "0",
 messageUserId = 5,
 messageCreateTime = 1543914721000,
 messageQuestionId = 2,
 messageContent = "【财务填报】财务填报002",
 messageType = "2",
 },
 {
 messageId = 131,
 messageReadFlag = "0",
 messageUserId = 5,
 messageCreateTime = 1543914720000,
 messageQuestionId = 1,
 messageContent = "【工业填报】工业填报001",
 messageType = "2",
 },
 {
 messageId = 134,
 messageReadFlag = "0",
 messageUserId = 5,
 messageCreateTime = 1543914720000,
 messageQuestionId = 1,
 messageContent = "【工业填报】工业填报001",
 messageType = "2",
 },
 ),
 pages = 2,
 current = 1,
 condition = <null>,
 asc = 1,
 total = 18,
 size = 10,
 ascs = <null>,
 offset = 0,
 limit = 2147483647,
 openSort = 0,
 descs = <null>,
 searchCount = 1,
 orderByField = <null>,
 },
 code = "0",
 }
 */

@end
